package com.qiall.common.entity;

import com.qiall.common.request.BaseResponse;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class PageResponse<T> extends BaseResponse {
    private static final long serialVersionUID = 3741077973448075614L;

    private List<T> dataList;
    private int total;
    private int pageSize;
    private int pageNum;

    public static PageResponse nullValue(PageQuery pageQuery) {
        PageResponse pageResponse = new PageResponse();
        pageResponse.setPageNum(pageQuery.getPageNum());
        pageResponse.setPageSize(pageQuery.getPageSize());
        pageResponse.setTotal(0);
        pageResponse.setDataList(new ArrayList());
        return pageResponse;
    }

    public static PageResponse withValue(PageQuery pageQuery, int total, List data) {
        PageResponse pageResponse=new PageResponse();
        pageResponse.setDataList(data);
        pageResponse.setTotal(total);
        pageResponse.setPageNum(pageQuery.getPageNum());
        pageResponse.setPageSize(pageQuery.getPageSize());
    return pageResponse;
    }
}
